From 6e2407759d5cb6002756f7de7e4506336a3ef098 Mon Sep 17 00:00:00 2001
From: sgakerru <sulmpx60@yandex.ru>
Date: Thu, 19 Oct 2023 02:51:50 +0400
Subject: [PATCH] Add link to wiki in new printer window (MOS-specific link)

(cherry picked from commit f6171d4da7af21ee2b1a40a9addd5eba031c9cbb)
---
 newprinter.py          | 14 ++++++++++++++
 ui/NewPrinterWindow.ui | 23 +++++++++++++++++++----
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/newprinter.py b/newprinter.py
index eee8b555..db330083 100644
--- a/newprinter.py
+++ b/newprinter.py
@@ -284,6 +284,7 @@ class NewPrinterGUI(GtkGUI):
                               "ntbkPPDSource",
                               "rbtnNPPPD",
                               "tvNPMakes",
+                              "linkBtnToWiki",
                               "rbtnNPFoomatic",
                               "filechooserPPD",
                               "rbtnNPDownloadableDriverSearch",
@@ -635,6 +636,19 @@ class NewPrinterGUI(GtkGUI):
         self.btnNetworkFind.set_sensitive (True)
         self.lblNetworkFindNotFound.hide ()
 
+        # Show link to wiki only if OS id match.
+        with open('/etc/os-release') as osReleaseF:
+            for line in osReleaseF:
+
+                if line.find("=") == -1:
+                    continue
+
+                key, value = line.split("=")
+
+                if key == 'ID' and value.strip() == 'mos':
+                    self.linkBtnToWiki.show ()
+                    break
+
         # Clear out any previous list of makes.
         model = self.tvNPMakes.get_model()
         model.clear()
diff --git a/ui/NewPrinterWindow.ui b/ui/NewPrinterWindow.ui
index ed6103d8..11b48d01 100644
--- a/ui/NewPrinterWindow.ui
+++ b/ui/NewPrinterWindow.ui
@@ -1504,6 +1504,21 @@ ipp://printer.mydomain/ipp</property>
                     <property name="can_focus">False</property>
                     <property name="orientation">vertical</property>
                     <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkLinkButton" id="linkBtnToWiki">
+                        <property name="label" translatable="yes">Инструкции и драйвера для некоторых моделей принтеров</property>
+                        <property name="visible">False</property>
+                        <property name="can-focus">True</property>
+                        <property name="receives-default">True</property>
+                        <property name="relief">none</property>
+                        <property name="uri">https://os.mos.ru/manuals/printers</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
                     <child>
                       <object class="GtkRadioButton" id="rbtnNPFoomatic">
                         <property name="label" translatable="yes">Select printer from database</property>
@@ -1519,7 +1534,7 @@ ipp://printer.mydomain/ipp</property>
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">False</property>
-                        <property name="position">0</property>
+                        <property name="position">1</property>
                       </packing>
                     </child>
                     <child>
@@ -1536,7 +1551,7 @@ ipp://printer.mydomain/ipp</property>
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">False</property>
-                        <property name="position">1</property>
+                        <property name="position">2</property>
                       </packing>
                     </child>
                     <child>
@@ -1554,7 +1569,7 @@ ipp://printer.mydomain/ipp</property>
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">False</property>
-                        <property name="position">2</property>
+                        <property name="position">3</property>
                       </packing>
                     </child>
                     <child>
@@ -1844,7 +1859,7 @@ ipp://printer.mydomain/ipp</property>
                       <packing>
                         <property name="expand">True</property>
                         <property name="fill">True</property>
-                        <property name="position">3</property>
+                        <property name="position">4</property>
                       </packing>
                     </child>
                   </object>
-- 
2.40.1

